<?xml version="1.0" encoding="utf-8" ?>
<Recipe xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  Name="AdministrationPage"
  xmlns="http://schemas.microsoft.com/pag/gax-core"
  Bound="false">
  <DocumentationLinks>
    <Link Caption="AdministrationPage" Url="http://msdn.microsoft.com/en-us/library/ms463449.aspx" Kind="Documentation"/>
  </DocumentationLinks>
  <xi:include href="../../../TypeAlias.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
  <Caption>Administration Page</Caption>
  <Description>Add an administration page to the project inherited from LayoutsPageBase</Description>
  <HostData>
    <Icon File="Help/Icons/icon_ApplicationPages.ico" />
    <CommandBar Menu="SPSFProjectApplicationPages"/>
    <spsf:MetaData
      Visible="true"
      BindingType="CustomizationReference"
      BindingTypeTemplate="CustomizationReferenceTemplate"
      TestType="BaseCustomizationRecipeRunner"
      Enabled="true"
      CreateVSTemplate="true"
	  NotSandboxSupported="true"
      Category="ApplicationPages" xmlns:spsf="http://www.spalmblogger.de">
      <spsf:Authors>
        <spsf:Author>Torsten Mandelkow</spsf:Author>
      </spsf:Authors>
      <spsf:VersionHistory>
        <spsf:VersionHistoryEntry>1.0 Initial Recipe</spsf:VersionHistoryEntry>
      </spsf:VersionHistory>
      <spsf:WebPageContent>
        <![CDATA[]]>
      </spsf:WebPageContent>
		<spsf:Test>
			<spsf:TestCases>
				<spsf:TestCase Name="DefaultAdministrationPage" Type="SolutionTestCase">
					<spsf:TestCaseArguments>
						<spsf:TestCaseArgument Name="ApplicationPageName">DefaultAdministrationPage</spsf:TestCaseArgument>
						<spsf:TestCaseArgument Name="ApplicationPageTitle">Custom Administration Page</spsf:TestCaseArgument>
						<spsf:TestCaseArgument Name="ApplicationPageDescription">Description of Custom Administration Page</spsf:TestCaseArgument>
					</spsf:TestCaseArguments>
					<spsf:TestExpectedDeployResults>
						<spsf:TestExpectedDeployResult Type="ManualCheck">Administration Page with title 'Administration Page' exists in central administration /_layouts/SolutionName/DefaultAdministrationPage.aspx</spsf:TestExpectedDeployResult>
					</spsf:TestExpectedDeployResults>
				</spsf:TestCase>
			</spsf:TestCases>
		</spsf:Test>
    </spsf:MetaData>
  </HostData>
  <Arguments>

    <xi:include href="../../BaseArguments.include" parse="xml" xpointer="xmlns(p=http://schemas.microsoft.com/pag/gax-core) xpointer(/p:Arguments/*)" xmlns:xi="http://www.w3.org/2001/XInclude" />

    <Argument Name="ResourceKeyPrefix" Required="true">
      <!-- provides the unique key with removed special chars -->
      <ValueProvider Stage="OnBeforeActions" RecipeArgument="ApplicationPageName" Type="ConvertedStringProvider" />
    </Argument>

    <Argument Name="ApplicationPageName"  Required="true">
      <Converter Type="NamespaceStringConverter" />
      <ValueProvider Type="VisualStudioCreateItemName" DefaultValue="AdministrationPage1" />      
    </Argument>
    <Argument Name="ApplicationPageTitle" Required="true">
      <ValueProvider Type="Evaluator" Expression="Page Title" />
    </Argument>
    <Argument Name="ApplicationPageDescription" Required="true">
      <ValueProvider Type="Evaluator" Expression="Page Description" />
    </Argument>

  </Arguments>
  <GatheringServiceData>
    <Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">
      <Pages>
        <Page Height="350">
          <Title>Layouts Page Name</Title>
          <Fields>
            <Field Label="Branding" ValueName="SPSFBranding" PanelType="SPALM.SharePointSoftwareFactory.Library.BrandingPanel, SPALM.SharePointSoftwareFactory.Library" />
            <Field ValueName="ApplicationPageName" Label="Name">
              <Help>Enter the name of the application page (without .aspx).</Help>
            </Field>
            <Field ValueName="ApplicationPageTitle" Label="Title" >
              <Help>Enter the title of page (displayed on top of the page and in the title of the html).</Help>
            </Field>
            <Field ValueName="ApplicationPageDescription" Label="Description" >
              <Help>Enter the description of page (displayed on top of the page).</Help>
            </Field>
          </Fields>
        </Page>
      </Pages>
    </Wizard>
  </GatheringServiceData>
  <Actions CoordinatorServiceType="ConditionalCoordinator">

    <xi:include href="../../BaseStartingActions.include" parse="xml" xpointer="xmlns(p=http://schemas.microsoft.com/pag/gax-core) xpointer(/p:Actions/*)" xmlns:xi="http://www.w3.org/2001/XInclude" />

    <Action
		  Name="AddASPXPage"
		  Type="AddSPDataTemplateAction"
      SPDataName="$(ApplicationPageName)"
      SPDataCategory="ApplicationPages"
      SPDataTemplate="Text\GenericSPData\SharePointProjectItem.spdata.t4"
		  TemplateFileName="Text\AdministrationPage\AdministrationPage.aspx.t4"
		  TargetFileName="$(ApplicationPageName).aspx"
      DeploymentType="TemplateFile"
		  DeploymentPath="ADMIN\$(SafeAppName)"
		  Open="true">
      <Output Name="CreatedProjectItem" />
      <Output Name="CreatedProjectFolder" />
    </Action>

    <Action
      Name="AddASPXCode"
      Type="AddTemplateToItemAction"
      DeploymentType="CustomCode"
      TemplateFileName="Text\AdministrationPage\AdministrationPage.cs.t4"
      TargetFileName="$(ApplicationPageName).cs">
      <Input Name="ParentProjectItem" ActionOutput="AddASPXPage.CreatedProjectItem" />
    </Action>

    <Action
      Condition="$(AutoCreateResxFiles)"
      Name="AddResources"
      Type="AddTemlateToResourcesFileAction"
      ApplicationResources="true"
      TemplateFileName="Text\AdministrationPage\Resources.resx.t4"
      ResourcesFileName="$(ResourceFilename).resx">
    </Action>

    <xi:include href="../../BaseFinalActions.include" parse="xml" xpointer="xmlns(p=http://schemas.microsoft.com/pag/gax-core) xpointer(/p:Actions/*)" xmlns:xi="http://www.w3.org/2001/XInclude" />

  </Actions>
</Recipe>